package com.nwpu.am.mapper;

import com.nwpu.am.pojo.entity.User;
import org.apache.ibatis.annotations.*;

/**
 * UserMapper
 *
 * @author Roy
 * @version 1.0
 * {@code @date} 2024/6/3
 */

@Mapper
public interface UserMapper {
    @Select("select user_id, username, password, phone_num, email, sex, address, birthday, role from tb_user where username = #{username}")
    User findByUsername(String username);
    @Select("SELECT * FROM tb_user WHERE user_id = #{userId}")
    User selectUserById(@Param("userId") Integer userId);

    @Insert("INSERT INTO tb_user (user_id, username, password, role, phone_num, address, email, birthday, sex) VALUES(#{userId}, #{username}, #{password}, #{role}, #{phoneNum}, #{address}, #{email}, #{birthday}, #{sex})")
    void insertUser(User user);

    int updateUser(User user);

    @Delete("DELETE FROM tb_user WHERE user_id = #{userId}")
    int deleteUser(@Param("userId") Integer userId);

}
